package com.day02.demo4;


public class Main {
    public static void main(String[] args) {
        //用接口类 给一个有普通收入、工资收入的小伙伴算税:
        Income[] incomes = new Income[] {
            
            new Salary(7500),
            new GaoFei(5000),
           
        };
        System.out.println(totalTax(incomes));
    }

    public static double totalTax(Income... incomes) {
        double total = 0;
        for (Income income: incomes) {
            total = total + income.getTax();
        }
        return total;
    }
}

interface Income {
    

  //default void Income() {}
  double getTax();
}

class Salary implements Income {
    private double income;
    public Salary(double income){
    	this.income = income;
    }
   public double getTax() {
        if (income <= 5000) {
            return 0;
        }
        return (income - 5000) * 0.2;
    }
}

class GaoFei implements Income{
	
	private double income;
	 
	public GaoFei(double income){
		this.income = income;
	}
	
	 public double getTax(){
		 return income*0.5; 
	 }
	 
 
}




